<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /* 一、创建类 */
    /*  class phone {
       // 构造方法 名字不能改
       constructor(brand, price) {
         this.brand = brand
         this.price = price
       }
       // 方法返回必须使用该语句
       call() {
         console.log('你好，calss');
       }
     }
     let curry = new phone('华为', '5999')
     console.log(curry); */
    /* 二、类的静态方法 */
    /*   
    class phone {
      static name = '123'
      static change() {
        console.log('456');
      }
    }
    let curry = new phone()
    console.log(phone.name);
    //undefined 
    // 因为static的方法属于类，而不属于实例对象
    console.log(curry.name); 
    */
    /* 三、类的继承 */
    /* 
    class phone {
      constructor(brand, price) {
        this.brand = brand
        this.price = price
      }
      call() {
        console.log('你好');
      }
    }
    class smartPhone extends phone {
      constructor(brand, price, color, size) {
        // 继承父类的属性
        super(brand, price)
        this.color = color
        this.size = size
      }
      photo() {
        console.log('好的');
      }
      // 子类对父类方法的重写
      call() {
        console.log('我不好');
      }
    }
    // 实例化
    let curry = new smartPhone('华为', 1999, '黑色', '1.55inch')
    console.log(curry);
    // 调用子类方法
    curry.photo()
    curry.call() 
    */
    /* 四、set、get方法 */
    class phone {
      get price() {
        console.log('你好');
        return '123'
      }
      // set方法里面必须写参数
      set price(el) {
        console.log('456');
      }
    }
    let curry = new phone()
    console.log(curry.price);
    // 给set随便赋一个值来触发set方法
    curry.price = ''
  </script>
</body>

</html>